//
//  TravelDetailCenterTableViewCell.swift
//  AirTravel
//
//  Created by apple on 2021/11/24.
//

import UIKit

class TravelDetailCenterTableViewCell: UITableViewCell ,UITableViewDelegate , UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return model?.ProductInfo?.ResourceList?.count ?? 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tab.dequeueReusableCell(withIdentifier: "TravelCenterPersonTableViewCell", for: indexPath) as! TravelCenterPersonTableViewCell
        
        cell.name.text = model?.ProductInfo?.ResourceList?[indexPath.row].Name
        
        var str = ""
        
        if(model?.ProductInfo?.ResourceList?[indexPath.row].DisplayTagGroupList?.count != 0){
            for mod in (model?.ProductInfo?.ResourceList?[indexPath.row].DisplayTagGroupList?.first?.DisplayTagList)!{
                str.append(mod.Value + " ")
            }
        }
        
        cell.detail.text = str
        cell.priceLabel.text =  model?.ProductInfo?.ResourceList?[indexPath.row].CtripPrice
        
//        switch indexPath.row {
//        case 0:
//            cell.name.text = "成人票"
//            cell.detail.text = "可订明日  无需取票"
//            cell.priceLabel.text = "118"
//
//        case 1:
//            cell.name.text = "儿童票"
//            cell.detail.text = "今日12:00前可预订"
//            cell.priceLabel.text = "118"
//        default:
//
//            cell.name.text = "学生票"
//            cell.detail.text = "今日12:00前可预订"
//            cell.priceLabel.text = "118"
//        }
        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 91
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tab.deselectRow(at: indexPath, animated: true)
    }

    @IBOutlet weak var tab: UITableView!
    @IBOutlet weak var twoBt: UIButton!
    @IBOutlet weak var firstBt: UIButton!
    
    var model:TravelDetailModel?
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
        
        tab.delegate = self
        tab.dataSource = self
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    
    func setUI(){
        self.tab.reloadData()
    }
    
}
